home *** CD-ROM | disk | FTP | other *** search
- {$R-}
- {
- SetPVolume -- An HyperCard XCMD that will set the volume of the speaker.
- and place the new volume into Parameter RAM. This
- routine will reset the control panel's volume level,
- so use it only when necessary.
-
- Written by Steven Kienle, CIS account number 72330,111
-
- SetPVolume should be called in HyperCard as
- SetPVolume(<volume>)
- Where <volume> is between 0 and 7.
-
- After compiling this program, link it with the SetPVolume.Link, then use
- ResEdit to move the XCMD resource to the appropriate stack. Or use the
- GetVolume/SetVolume stack's Install SetPVolume button.
-
- NOTE: for the XCmdGlue.inc file to work with TML Pascal, a few
- modifications are required.
- }
-
- {$S SetPVolume } { Segment name must be the same as the command name. }
-
- UNIT DummyUnit;
-
- INTERFACE
-
- USES MacIntf, HyperXCmd;
-
- PROCEDURE ENTRYPOINT(paramPtr: XCmdPtr);
-
- IMPLEMENTATION
-
- PROCEDURE SetPVolume(paramPtr: XCmdPtr); FORWARD;
-
- PROCEDURE ENTRYPOINT(paramPtr: XCmdPtr);
- BEGIN
- SetPVolume(paramPtr);
- END;
-
- PROCEDURE SetPVolume(paramPtr: XCmdPtr);
- VAR
- newVolume : LongInt ;
- pasStr : Str255 ;
- tempStr : Str31 ;
- theParams : SysPPtr ;
- theError : OSErr ;
- Top5, Bottom8, VolBits : Integer ;
-
- {$I XCmdGlue.inc }
-
- BEGIN
- ZeroToPas(paramPtr^.params[1]^,pasStr) ; { first param is Volume }
- tempStr := pasStr ;
- newVolume := StrToNum(tempStr) ;{ Convert it to a Number }
-
- { Reset the Volume in the Parameter RAM }
-
- theParams := GetSysPPtr ;
- Bottom8 := BitAnd(theParams^.volClik,$00FF) ;
- Top5 := BitAnd(theParams^.volClik, $F800) ;
- VolBits := newVolume * $0100 ;
- theParams^.volClik := Top5 + VolBits + Bottom8 ;
- theError := WriteParam ;
-
- { If there was an error, let the user know }
-
- If theError <> noErr then
- SendCardMessage('answer "Big Trouble with writing Parameter Ram" with "OK"') ;
-
- SetSoundVol (newVolume) ; { Set the Current Volume }
- END;
-
- END.
-